﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ValidationFramework.Fluent.Facts.TestModel;
using ValidationFramework.Reflection;
using Xunit;

namespace ValidationFramework.Fluent.Facts
{
	public class PropertyInfoFacts
	{
		[Fact]
		public void Should_Add_Rule_To_Correct_PropertyDescriptor()
		{
			// arrange
			Validation.ClearRulesFor<Product>();
			Assert.True(TypeCache.GetType<Product>().GetRuleCount() == 0, "The type helping with test should have no validation rules");

			// act
			var propertyInfo = new PropertyInfo<Product>(x => x.Name);
			propertyInfo.Passes(new RequiredStringRule());

			// assert
			Assert.True(TypeCache.GetType<Product>().GetRuleCount() == 1, "A rule should have been added");
		}
	}
}
